<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/security/tags"
           prefix="sec" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.joda.org/joda/time/tags" prefix="joda" %>
<%@ page import="org.jackysoft.query.*" %>
<%@ page import="org.jackysoft.report.ProductValidation" %>

<%@page import="org.jackysoft.util.*" %>
<style>
    .logic-control {
        width: 80px;
    }
</style>
<%
    request.setAttribute("inoprs", CompareRelation.getOptions());
    request.setAttribute("outoprs", LogicRelation.getOptions());
    request.setAttribute("validations", ProductValidation.getOptions(false));
%>
<div class="alert alert-info">
 合同综合查询统计分析
</div>
<h4>综合统计查询</h4>
<form class="form-horizontal">
  		<input type="hidden" name="query.state" value="START"/>
        <input id="sqlid" type="hidden" name="query.sqlId" value="statAllByCode"/>
        <DIV class=control-group>
          <LABEL class="control-label" >按产品统计</LABEL>
          <DIV class=controls>
          <input type="hidden" name="query.fields[0].name" value="year(firedate)"/>
          <select name="query.fields[0].value" class="logic-control" >
  			<option value="2013">2013</option>
  			<option value="2014">2014</option>
		  </select>
          <button class="btn btn-info" 
                    type="button"
                    onclick="statAll(this)">
                <i class="icon-white icon-search"></i>按产品统计
          </button>
          
          </DIV>
        </DIV>      
</form>
<form class="form-horizontal">

    <input type="hidden" name="query.state" value="START"/>
    
        <DIV class=control-group>
            <!-- 按验收状态总览 -->
            <LABEL class=control-label for=vadInput>按验收状态</LABEL>
            <DIV class=controls>
              <input type="hidden" name="query.sqlId" value="statByValidation"/>            
              <input type="hidden" name="query.fields[0].name" value="year(firedate)"/>
          <select name="query.fields[0].value"  class="logic-control" >
  			<option value="2013">2013</option>
  			<option value="2014">2014</option>
		  </select>
              <BUTTON class="btn btn-info" 
                      type="button"
                      onclick="collectAll(this)">
                  <i class="icon-white icon-search"></i>按验收状态汇总
              </BUTTON>
            </DIV>
         </DIV>        
     
</form>     


 <!-- 按订货单位 -->
<form class="form-horizontal">

    <input type="hidden" name="query.state" value="START"/>
    
        <DIV class=control-group>
            <LABEL class=control-label for=unitInput>按订货单位</LABEL>

            <DIV class=controls>
                <input type="hidden" name="query.sqlId" value="statByClient"/>
                <input type="hidden" name="query.fields[0].name" value="year(firedate)"/>
          <select name="query.fields[0].value" class="logic-control" >
  			<option value="2013">2013</option>
  			<option value="2014">2014</option>
		  </select>
                <BUTTON class="btn btn-info" 
                      type="button"
                      onclick="collectAll(this)">
                  <i class="icon-white icon-search"></i>按订货单位汇总
              </BUTTON>
            </DIV>
        </DIV>
</form>

  <!--按季度-->
<form class="form-horizontal">
 <input type="hidden" name="query.state" value="START"/>
 <input type="hidden" name="query.sqlId" value="statByQuarter"/>   
          
            <DIV class=control-group>
            <LABEL class=control-label for=nameInput>按季度</LABEL>

            <DIV class=controls>
                 <input type="hidden" name="query.fields[0].name" value="year(firedate)"/>
          <select name="query.fields[0].value" class="logic-control" >
  			<option value="2013">2013</option>
  			<option value="2014">2014</option>
		  </select>                    
                <BUTTON class="btn btn-info" 
                      type="button"
                      onclick="collectAll(this)">
                  <i class="icon-white icon-search"></i>按季度汇总
              </BUTTON>
            </DIV>
            </DIV>
</form>
  <!--按月份-->
<form class="form-horizontal">
 <input type="hidden" name="query.state" value="START"/>
 <input type="hidden" name="query.sqlId" value="statByMonth"/>   
          
            <DIV class=control-group>
            <LABEL class=control-label for=nameInput>按月份统计</LABEL>

            <DIV class=controls>
                           <input type="hidden" name="query.fields[0].name" value="year(firedate)"/>
          <select name="query.fields[0].value" class="logic-control" >
  			<option value="2013">2013</option>
  			<option value="2014">2014</option>
		  </select>          
                <BUTTON class="btn btn-info" 
                      type="button"
                      onclick="collectAll(this)">
                  <i class="icon-white icon-search"></i>按月份统计
              </BUTTON>
            </DIV>
            </DIV>
</form> 


<!-- 组合查询明细  -->

<form class="form-horizontal">
    <input id="sqlid2" type="hidden" name="query.sqlId" value="statAllByDate"/>
    <input id="sqlid2" type="hidden" name="query.resultCode" value="details"/>
    <input type="hidden" name="query.state" value="START"/>
    <FIELDSET sizset="3">
        <LEGEND><h4>合同组合查询</h4></LEGEND>
        <DIV class=control-group>
            <LABEL class=control-label for=focusedInput>产品代码</LABEL>

            <DIV class=controls>
                <input type="checkbox" onclick="toggleDisabled(this)" checked="true">
                <input type="hidden" name="query.fields[0].name" value="a.code"/>
                <select name="query.fields[0].inOpr" class="logic-control">
                    ${inoprs}
                </select>
                <INPUT id=focusedInput class="input-xlarge focused"
                       name="query.fields[0].value" type="text">

                <select
                        name="query.fields[0].outOpr" class="logic-control">
                    ${outoprs}
                </select>

            </DIV>


            <LABEL class=control-label for=unitInput>订货单位</LABEL>

            <DIV class=controls>
                <input type="checkbox" onclick="toggleDisabled(this)" checked="true">
                <input type="hidden" name="query.fields[1].name" value="a.ccid"/>
                <select id=unitInput  name="query.fields[1].value">
                    <c:forEach items="${clients}" var="client">
                        <option value="${client.id}">${client.name}</option>
                    </c:forEach>

                </select> <select name="query.fields[1].outOpr" class="logic-control">
                ${outoprs}
            </select>

            </DIV>

            <LABEL class=control-label for=nameInput>合同号</LABEL>

            <DIV class=controls>
                <input type="checkbox" onclick="toggleDisabled(this)" checked="true">
                <input type="hidden" name="query.fields[2].name" value="a.ctname"/>
                <select id=nameInput name="query.fields[2].value"
                        class="input-xlarge focused">
                    <c:forEach items="${stringList}" var="name">
                        <option value="${name}">${name}</option>

                    </c:forEach>


                </select>

                <select
                        class="logic-control" name="query.fields[2].outOpr">
                    ${outoprs}
                </select>

            </DIV>

            <LABEL class=control-label for=vadInput>验收状态</LABEL>

            <DIV class=controls>
                <input type="checkbox" onclick="toggleDisabled(this)" checked="true">
                <input type="hidden" name="query.fields[3].name" value="a.validation"/>
                <select id=vadInput name="query.fields[3].value"
                        class="logic-control focused">
                    ${validations}
                </select> 
                <select name="query.fields[3].outOpr" class="logic-control">
                ${outoprs}
            </select>

            </DIV>

            <LABEL class=control-label for=remarkInput>生产单位</LABEL>

            <DIV class=controls>
                <input type="checkbox" onclick="toggleDisabled(this)" checked="true">
                <input type="hidden" name="query.fields[5].name" value="a.deptId"/>
                <input type="hidden" name="query.fields[5].inOpr" value="等于"/>
                <select name="query.fields[5].value" id="deptlist">

                </select>
                <select name="query.fields[5].outOpr" class="logic-control">
                ${outoprs}
            </select>
            </DIV>

			<LABEL class=control-label>按年份</LABEL>

            <DIV class=controls>
                <input type="checkbox" onclick="toggleDisabled(this)" checked="true">
                

                <select name="query.fields[10].value" class="logic-control">
                    <option value="2013">2013</option>
                    <option value="2014">2014</option>
                    
                </select>
                <input type="hidden" name="query.fields[10].inOpr" value="等于">
                <input type="hidden" name="query.fields[10].value" value="year(firedate)"/>
                 <select name="query.fields[7].outOpr" class="logic-control">
                ${outoprs}
            </select>
            </DIV>


            <LABEL class=control-label>按季度</LABEL>

            <DIV class=controls>
                <input type="checkbox" onclick="toggleDisabled(this)" checked="true">
                <input type="hidden" name="query.fields[6].name" value="YEAR(firedate)">
                <select name="query.fields[6].value" class="logic-control">
                    <option value="2013">2013</option>
                    <option value="2012">2012</option>
                </select>
                <input type="hidden" name="query.fields[6].outOpr" value="并且">

                <select name="query.fields[7].name" class="logic-control">
                    <option value="(a.jan+a.feb+a.mar)">一季度</option>
                    <option value="(a.apr+a.may+a.jun)">二季度</option>
                    <option value="(a.jul+a.aug+a.sep)">三季度</option>
                    <option value="(a.oct+a.nov+a.dec)">四季度</option>
                </select>
                <input type="hidden" name="query.fields[7].inOpr" value="大于">
                <input type="hidden" name="query.fields[7].value" value="0"/>
              <select name="query.fields[7].outOpr" class="logic-control">
                ${outoprs}
            </select>
            </DIV>

            <%
                Months[] ms = Months.values();
                pageContext.setAttribute("months", ms);
                //Weeks[] ws = Weeks.values();
            %>
            <LABEL class=control-label>按月份</LABEL>

            <DIV class=controls>
                <input type="checkbox" onclick="toggleDisabled(this)" checked="true">
                <input type="hidden" name="query.fields[8].name" value="year(firedate)">
                <select name="query.fields[8].value" class="logic-control">
                    <option value="2013">2013</option>
                </select>
                <input type="hidden" name="query.fields[8].outOpr" value="并且"/>
                <select name="query.fields[9].name" class="logic-control">
                    <c:forEach items="${months}" var="m">
                        <option value="${m.name}">${m.label}月份</option>
                    </c:forEach>
                </select>
                <input type="hidden" name="query.fields[9].inOpr" value="大于">
                <input type="hidden" name="query.fields[9].value" value="0"/>
                <select name="query.fields[9].outOpr" class="logic-control">
                ${outoprs}
            </select>
            </DIV>
            
            
            
            
            
            <label class="control-label">排序格式</label>

            <div class="controls">
                <input type="checkbox" onclick="toggleDisabled(this)" checked="true">
                <select
                        name="query.orders[0].name">
                    <option value="a.contracttype">合同类型</option>
                    <option value="a.validation">验收方式</option>
                    <option value="a.ccid">客户</option>
                    <option value="a.fireDate">签订时间</option>
                    <option value="a.deptId">生产单位</option>
                </select>
                <select class="logic-control" name="query.orders[0].style">
                    <option value="desc">降序</option>
                    <option value="asc">升序</option>
                </select>

            </div>
        </DIV>
        <DIV class=form-actions>
            <BUTTON class="btn btn-primary" type="button"
                    onclick="statAll(this)">
                <i class="icon-white icon-search"></i>查询
            </BUTTON>
        </DIV>
    </FIELDSET>
</form> 

<script type="text/javascript" src="scripts/apps/contract/search.js"></script>